<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="app">
    <input type="text" v-model="msg">
    {{ msg2 }}
    <button @click="change">改变计算属性的值</button>
  </div>
  <script>
    let vm = new Vue({
      el:"#app",
      data:{
        msg:'hello world',
        num:123
      },
      methods:{
        change(){
          this.msg2 = "12345";
        },
        reverseMsg(){
          console.log("method调用了")
          return this.msg.split('').reverse().join('')
        }
      },
      computed:{
      
       msg2:{
         get(){
           console.log("我是get拦截，你在使用msg2计算属性时会触发")
           return this.msg.split("").reverse().join('');
         },
         set(val){
          console.log(val+"set触发了");
          this.msg = val;
         }
       }
      }
    })
    console.log(vm)
  </script>
</body>
</html>